/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.dao.hibernate;

import com.click.app.dao.CatalogDao;
import com.click.app.model.LabelValue;
import com.click.app.model.Catalog;
import com.click.app.model.Category;
import java.util.List;

/**
 *
 * @author arnold
 */
public class CatalogDaoHibernate extends GenericDaoHibernate<Catalog, Long> implements CatalogDao {
    List<LabelValue> catalogLabelValueList;
    public CatalogDaoHibernate() {
        super(Catalog.class);
    }


    public List<Catalog> findById(Long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<Catalog> findCatalogByCategory(Category category) {
       List listCatalogs = getHibernateTemplate().find("from Catalog where category=?", category);
       return listCatalogs;
    }

    public Catalog findCurrentCatalog(){
        List listCatalogs = getHibernateTemplate().find("from Catalog where actual=true");
        if(!listCatalogs.isEmpty()){
            return (Catalog)listCatalogs.get(0);
        }
        return null;
    }
}

